Full source code website bán hàng thương mại điện tử gần giống shopee
468.914 lượt xem;
1 <table height="28" cellSpacing="0" cellPadding="0" width="100%" border="0">
2 <tr align=center>
3 <td class="title" width="100%" height="17">
4 Danh mục rao vặt : <b> <a href="./?act=cat_adv_m&page=<? echo $_REQUEST['page']; ?>&cat=<? echo $_REQUEST['cat']; ?>"><font color="#FFFFFF">Nhập
5 Mới</font></a><font color="#FFFFFF"> </font></b></td>
6 </tr>
7 </table>
8 <?
9
10 $MAXPAGE=20;
11
12 switch ($_GET['action'])
13 {
14 case 'del' :
15 $id = $_GET['id'];
16 $result = mysql_query("select adv_cat from avd where adv_cat='".$id."'",$con);
17 if (mysql_num_rows($result)<=0) {
18 $sql = "delete from adv_cat where id='".$id."'";
19 @$result = mysql_query($sql,$con);
20 if ($result) echo "<p align=center class='err'>Đã xóa thành công</p>";
21 else echo "<p align=center class='err'>Không thể xóa dữ liệu</p>";
22 } else {
23 echo "<p align=center class='err'>Đang có sản phẩm sử dụng. nên bạn không thể xóa</p>";
24 }
25
26 break;
27 }
28 ?>
29
30 <?
31 if (isset($_POST['ButDel'])) {
32 $cnt=0;
33 foreach ($_POST['chk'] as $id)
34 {
35 @$result = mysql_query("delete from adv_cat where id='".$id."'",$con);
36 if ($result) $cnt++;
37 }
38 echo "<p align=center class='err'>Đã xóa ".$cnt." phần tử</p>";
39 }
40 ?>
41 <?
42 $page = $_GET["page"];
43 $p=0;
44 if ($page!='') $p=$page;
45 $where="1=1";
46 if ($_REQUEST['cat']!='') $where="parent=".$_REQUEST['cat'];
47 ?>
48 <form method="POST" action="<? echo $_SERVER[PHP_SELF]; ?>" name="frmList">
49 <input type=hidden name="page" value="<? echo $page; ?>">
50 <?
51 function taotrang($sql,$link,$nitem,$itemcurrent)
52 { global $con;
53 $ret="";
54 $result = mysql_query($sql, $con) or die('Error' . mysql_error());
55 $value = mysql_fetch_array($result);
56 $plus = (($value['cnt'] % $nitem)>0);
57 for ($i=0;$i<($value[0] / $nitem) + plus;$i++)
58 {
59 if ($i<>$itemcurrent) $ret .= "<a href=\"".$link.$i."\" class=\"lslink\">".($i+1)."</a> ";
60 else $ret .= ($i+1)." ";
61 }
62 return $ret;
63 }
64 $pageindex=taotrang("select count(*) from adv_cat where $where","./?act=cat_adv&cat=".$_REQUEST['cat']."&page=",$MAXPAGE,$page);
65 ?>
66
67 <table cellspacing="0" cellpadding="0" width="100%">
68 <tr>
69 <td class="smallfont">Trang : <? echo $pageindex; ?></td>
70 <td height="30" align="right" class="smallfont">
71 <select size="1" name="ddCat" class="smallfont">
72 <?
73 $ms=GetListAdv(0);
74 echo '<option value="">[Tất cả]</option>';
75 foreach ($ms as $m)
76 if ($m[0]!=$_REQUEST['cat'])
77 echo '<option value="'.$m[0].'">'.$m[1].'</option>';
78 else
79 echo '<option selected value="'.$m[0].'">'.$m[1].'</option>';
80 ?>
81 </select>
82 <input type="button" value="Chuyển" class="button" onclick="window.location='./?act=cat_adv&cat='+ddCat.value">
83 </td>
84 </tr>
85 </table>
86
87 <table border="1" cellpadding="2" style="border-collapse: collapse" bordercolor="#C9C9C9" width="100%" id="AutoNumber1">
88 <tr>
89 <td align=center nowrap class="title"><input type="checkbox" name="chkall" onclick="chkallClick(this);"></td>
90 <td nowrap class="title"> </td>
91 <td nowrap class="title"> </td>
92 <td align="center" nowrap class="title"><b>Mã</b></td>
93 <td align="center" nowrap class="title"><b>Tên danh mục</b></td>
94 <td align="center" nowrap class="title"><b>Thuộc danh mục</b></td>
95 <td align="center" nowrap class="title"><b>Thứ tự sắp xếp</b></td>
96 </tr>
97
98 <?
99 $sql="select * from adv_cat where $where order by id limit ".($p*$MAXPAGE).",".$MAXPAGE;
100 $result=mysql_query($sql,$con);
101 $i=0;
102 while(($row=mysql_fetch_array($result)))
103 {
104 $i++;
105 if ($i%2) $color="#d5d5d5"; else $color="#e5e5e5";
106 ?>
107
108 <tr>
109 <td width="20" align="center" bgcolor="<? echo $color; ?>" class="smallfont">
110 <input type="checkbox" name="chk[]" value="<? echo $row['id']; ?>"></td>
111 <td width="20" bgcolor="<? echo $color; ?>" class="smallfont">
112 <a href="./?act=cat_adv_m&cat=<? echo $_REQUEST['cat']; ?>&page=<? echo $_REQUEST['page']; ?>&id=<? echo $row['id']; ?>">
113 Sửa</a></td>
114 <td width="20" bgcolor="<? echo $color; ?>" class="smallfont">
115 <a href="./?act=cat_adv&action=del&page=<? echo $_REQUEST['page']; ?>&id=<? echo $row['id']; ?>">
116 Xoá</a></td>
117 <td width="20" bgcolor="<? echo $color; ?>" align="left" width="55" align="left" class="smallfont"><? echo $row['id']; ?> </td>
118 <td bgcolor="<? echo $color; ?>" class="smallfont"><? echo $row['name']; ?> </td>
119 <td width="80" bgcolor="<? echo $color; ?>" class="smallfont"><? echo $row['parent']; ?> </td>
120 <td width="80" bgcolor="<? echo $color; ?>" class="smallfont"><? echo $row['thutu']; ?> </td>
121 </tr>
122 <?
123 }
124 ?>
125 </table>
126 <input type="submit" value="Xóa Chọn" name="ButDel" onclick="return confirm('Bạn có chắc chắn muốn xoá ?');" class="button" style="padding: 0">
127 <input type="hidden" name="act" value="category">
128 </form>
129 <script language="JavaScript">
130 function chkallClick(o) {
131 var form = document.frmList;
132 for (var i = 0; i < form.elements.length; i++) {
133 if (form.elements[i].type == "checkbox" && form.elements[i].name!="chkall") {
134 form.elements[i].checked = document.frmList.chkall.checked;
135 }
136 }
137 }
138 </script>
2 <tr align=center>
3 <td class="title" width="100%" height="17">
4 Danh mục rao vặt : <b> <a href="./?act=cat_adv_m&page=<? echo $_REQUEST['page']; ?>&cat=<? echo $_REQUEST['cat']; ?>"><font color="#FFFFFF">Nhập
5 Mới</font></a><font color="#FFFFFF"> </font></b></td>
6 </tr>
7 </table>
8 <?
9
10 $MAXPAGE=20;
11
12 switch ($_GET['action'])
13 {
14 case 'del' :
15 $id = $_GET['id'];
16 $result = mysql_query("select adv_cat from avd where adv_cat='".$id."'",$con);
17 if (mysql_num_rows($result)<=0) {
18 $sql = "delete from adv_cat where id='".$id."'";
19 @$result = mysql_query($sql,$con);
20 if ($result) echo "<p align=center class='err'>Đã xóa thành công</p>";
21 else echo "<p align=center class='err'>Không thể xóa dữ liệu</p>";
22 } else {
23 echo "<p align=center class='err'>Đang có sản phẩm sử dụng. nên bạn không thể xóa</p>";
24 }
25
26 break;
27 }
28 ?>
29
30 <?
31 if (isset($_POST['ButDel'])) {
32 $cnt=0;
33 foreach ($_POST['chk'] as $id)
34 {
35 @$result = mysql_query("delete from adv_cat where id='".$id."'",$con);
36 if ($result) $cnt++;
37 }
38 echo "<p align=center class='err'>Đã xóa ".$cnt." phần tử</p>";
39 }
40 ?>
41 <?
42 $page = $_GET["page"];
43 $p=0;
44 if ($page!='') $p=$page;
45 $where="1=1";
46 if ($_REQUEST['cat']!='') $where="parent=".$_REQUEST['cat'];
47 ?>
48 <form method="POST" action="<? echo $_SERVER[PHP_SELF]; ?>" name="frmList">
49 <input type=hidden name="page" value="<? echo $page; ?>">
50 <?
51 function taotrang($sql,$link,$nitem,$itemcurrent)
52 { global $con;
53 $ret="";
54 $result = mysql_query($sql, $con) or die('Error' . mysql_error());
55 $value = mysql_fetch_array($result);
56 $plus = (($value['cnt'] % $nitem)>0);
57 for ($i=0;$i<($value[0] / $nitem) + plus;$i++)
58 {
59 if ($i<>$itemcurrent) $ret .= "<a href=\"".$link.$i."\" class=\"lslink\">".($i+1)."</a> ";
60 else $ret .= ($i+1)." ";
61 }
62 return $ret;
63 }
64 $pageindex=taotrang("select count(*) from adv_cat where $where","./?act=cat_adv&cat=".$_REQUEST['cat']."&page=",$MAXPAGE,$page);
65 ?>
66
67 <table cellspacing="0" cellpadding="0" width="100%">
68 <tr>
69 <td class="smallfont">Trang : <? echo $pageindex; ?></td>
70 <td height="30" align="right" class="smallfont">
71 <select size="1" name="ddCat" class="smallfont">
72 <?
73 $ms=GetListAdv(0);
74 echo '<option value="">[Tất cả]</option>';
75 foreach ($ms as $m)
76 if ($m[0]!=$_REQUEST['cat'])
77 echo '<option value="'.$m[0].'">'.$m[1].'</option>';
78 else
79 echo '<option selected value="'.$m[0].'">'.$m[1].'</option>';
80 ?>
81 </select>
82 <input type="button" value="Chuyển" class="button" onclick="window.location='./?act=cat_adv&cat='+ddCat.value">
83 </td>
84 </tr>
85 </table>
86
87 <table border="1" cellpadding="2" style="border-collapse: collapse" bordercolor="#C9C9C9" width="100%" id="AutoNumber1">
88 <tr>
89 <td align=center nowrap class="title"><input type="checkbox" name="chkall" onclick="chkallClick(this);"></td>
90 <td nowrap class="title"> </td>
91 <td nowrap class="title"> </td>
92 <td align="center" nowrap class="title"><b>Mã</b></td>
93 <td align="center" nowrap class="title"><b>Tên danh mục</b></td>
94 <td align="center" nowrap class="title"><b>Thuộc danh mục</b></td>
95 <td align="center" nowrap class="title"><b>Thứ tự sắp xếp</b></td>
96 </tr>
97
98 <?
99 $sql="select * from adv_cat where $where order by id limit ".($p*$MAXPAGE).",".$MAXPAGE;
100 $result=mysql_query($sql,$con);
101 $i=0;
102 while(($row=mysql_fetch_array($result)))
103 {
104 $i++;
105 if ($i%2) $color="#d5d5d5"; else $color="#e5e5e5";
106 ?>
107
108 <tr>
109 <td width="20" align="center" bgcolor="<? echo $color; ?>" class="smallfont">
110 <input type="checkbox" name="chk[]" value="<? echo $row['id']; ?>"></td>
111 <td width="20" bgcolor="<? echo $color; ?>" class="smallfont">
112 <a href="./?act=cat_adv_m&cat=<? echo $_REQUEST['cat']; ?>&page=<? echo $_REQUEST['page']; ?>&id=<? echo $row['id']; ?>">
113 Sửa</a></td>
114 <td width="20" bgcolor="<? echo $color; ?>" class="smallfont">
115 <a href="./?act=cat_adv&action=del&page=<? echo $_REQUEST['page']; ?>&id=<? echo $row['id']; ?>">
116 Xoá</a></td>
117 <td width="20" bgcolor="<? echo $color; ?>" align="left" width="55" align="left" class="smallfont"><? echo $row['id']; ?> </td>
118 <td bgcolor="<? echo $color; ?>" class="smallfont"><? echo $row['name']; ?> </td>
119 <td width="80" bgcolor="<? echo $color; ?>" class="smallfont"><? echo $row['parent']; ?> </td>
120 <td width="80" bgcolor="<? echo $color; ?>" class="smallfont"><? echo $row['thutu']; ?> </td>
121 </tr>
122 <?
123 }
124 ?>
125 </table>
126 <input type="submit" value="Xóa Chọn" name="ButDel" onclick="return confirm('Bạn có chắc chắn muốn xoá ?');" class="button" style="padding: 0">
127 <input type="hidden" name="act" value="category">
128 </form>
129 <script language="JavaScript">
130 function chkallClick(o) {
131 var form = document.frmList;
132 for (var i = 0; i < form.elements.length; i++) {
133 if (form.elements[i].type == "checkbox" && form.elements[i].name!="chkall") {
134 form.elements[i].checked = document.frmList.chkall.checked;
135 }
136 }
137 }
138 </script>